package com.changgou.seckill.exception;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author liyipeng
 * @date 2021-06-26 19:25
 */
@ControllerAdvice
public class GoodsGlobalException {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result exception(Exception e){
        //获取错误信息打印到日志里面
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR,e.getMessage());
    }

}
